<template>
	<view class="pageview">
		<cl-navbar leftIconSize="40rpx" placeholder :autoBack="false" leftIcon="">
		</cl-navbar>

		<view class="pageContent">
			<view class="centerTop">
				<view class="centerTop__view" @click="goPage('my_setting_info')">
					<view class="centerTop__view__topview">
						<cl-avatar :src="user_info.avatar_url" size="140rpx" preview></cl-avatar>
						<view class="centerTop__view__topview__info">
							<view style="display: flex;align-items: center;">
								<text class="centerTop__view__topview__info__nickname">Hi“ {{user_info.nick_name}}</text>
								<text
									v-if="user_info.user_type && user_info.user_type > 0 && user_info.user_type != 6 && user_info.user_type != 8"
									class="typetag"
									style="background-color: #02D478;">{{$t('common.friend.authority')}}</text>
							</view>
							<view style="display: flex;align-items: center;margin-top: 10rpx;" @click.stop="copy">
								<text
									class="centerTop__view__topview__info__account">{{$t('my.index.account')}}：{{user_info.user_no}}</text>
								<u-icon name="file-text" size="15px"></u-icon>
							</view>
						</view>
					</view>
					<u-icon name="arrow-right" color="#333333" size="20px" style="margin-right: 20rpx;"></u-icon>
				</view>
				<view class="centerTop__signature u-line-3">
					{{$t("addressbook.friend_details.signature")}}：<span>{{user_info.sign_remark || $t("my.index.noSignature")}}</span> 
				</view>
				<!-- <view class="memberCenter">
					<view class="memberCenter__left">
						<text class="memberCenter__left__title">{{$t("my.index.vipCenter")}}</text>
						<text class="memberCenter__left__deilte">{{$t("my.index.vipDetails")}}</text>
					</view>
					<view class="memberCenter__right" @click="goPage('vipPay')">
						{{$t("my.index.openVip")}}
					</view>
				</view> -->
			</view>
			<view class="cellviewGrop" @click="goPage('purse')">
				<view class="cellview">
					<view class="cellview__left">
						<image class="cellview__left__img" src="/static/icon/qianbao.svg" mode=""></image>
						<text class="cellview__left__title">{{ $t('my.index.purse') }}</text>
					</view>
					<u-icon name="arrow-right" :customStyle="iconstyle"></u-icon>
				</view>
			</view>
			<view class="cellviewGrop" @click="goPage('inviteRewards')">
				<view class="cellview">
					<view class="cellview__left">
						<image class="cellview__left__img" src="/static/icon/yaoqing.svg" mode=""></image>
						<text class="cellview__left__invite">{{ $t('my.index.inviteRewards') }}</text>
					</view>
					<view class="cellview__right">
						<text class="cellview__right__deilis">{{$t("my.index.promotionIncentive")}}</text>
						<u-icon name="arrow-right" :customStyle="iconstyle"></u-icon>
					</view>
				</view>
			</view>
			<view class="cellviewGrop" @click="user_info.real_name_auth_status !=2 ? goPage('realName') : ''">
				<view class="cellview">
					<view class="cellview__left">
						<image class="cellview__left__img" src="/static/icon/shimingrenzheng.svg" mode=""></image>
						<text class="cellview__left__title">{{ $t('my.index.realName') }}</text>
					</view>
					<view class="cellview__right">
						<text :class="['cellview__right__' + realNameClass]">{{realNameText}}</text>
						<u-icon name="arrow-right" :customStyle="iconstyle"></u-icon>
					</view>
				</view>
			</view>
			<view class="cellviewGrop" v-for="(setting, settingIndex) in settingList" :key="settingIndex" @click="goPage(setting.url)">
				<view class="cellview">
					<view class="cellview__left">
						<image class="cellview__left__img" :src="setting.icon" mode=""></image>
						<text class="cellview__left__title">{{ setting.name }}</text>
					</view>
					<u-icon name="arrow-right" :customStyle="iconstyle"></u-icon>
				</view>
			</view>
		</view>

		<!-- <cl-tabbar :currentTab="3"></cl-tabbar> -->
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				iconstyle: {
					'color': '#B2B2B2'
				},
			};
		},
		computed: {
			...mapState({
				user_info: state => state.user.user_info,
			}),
			settingList() {
				return [{
						icon: '/static/icon/shoucang_m.svg',
						url: 'collect',
						name: this.$t('my.index.collect')
					},
					{
						icon: '/static/icon/yinsianquan.svg',
						url: 'privacy_security',
						name: this.$t('my.index.privacySecurity')
					},
					{
						icon: '/static/icon/xiaoxitongzhi.svg',
						url: 'my_setting_notification',
						name: this.$t('my.index.notification')
					},
					{
						icon: '/static/icon/shezhi.svg',
						url: 'my_setting',
						name: this.$t('my.index.setting')
					}
				]
			},
			realNameText(){
				if(this.user_info.real_name_auth_status == '1'){
					return this.$t("my.index.certificationAudit")
				}else if(this.user_info.real_name_auth_status == '2'){
					return this.$t("my.index.authenticated")
				}else if(this.user_info.real_name_auth_status == '3'){
					return this.$t("my.index.authenticationFail")
				}else{
					return this.$t("my.index.notCertifiedYet")
				}
			},
			realNameClass(){
				if(this.user_info.real_name_auth_status == '1'){
					return 'deilis'
				}else if(this.user_info.real_name_auth_status == '2'){
					return 'success'
				}else if(this.user_info.real_name_auth_status == '3'){
					return 'failed'
				}else{
					return 'deilis'
				}
			},
		},
		async onLoad() {
			// uni.hideTabBar()
			this.getinfo()
		},
		methods: {
			async getinfo(){
				try{
					let apires = await this.$api.user.info()
					if(apires){
						//更新用户信息
						this.$store.dispatch('uploadUserInfo', apires.data)
					}
				}catch(e){
					//TODO handle the exception
				}
			},
			copy() {
				uni.setClipboardData({
					data: this.user_info.user_no,
					showToast: false,
					success: () => {
						uni.showToast({
							icon: 'none',
							title: this.$t("tost.title.copyOk")
						})
					}
				});
			},
			goPage(urlname) {
				this.$Router.push({
					name: urlname
				})
			}
		}
	};
</script>

<style scoped lang="scss">
	.memberCenter{
		width: 100%;
		height: 120rpx;
		background: linear-gradient(to right, #e6c484, #e7b057);
		margin-top: 30rpx;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		box-sizing: border-box;
		&__left{
			display: flex;
			flex-direction: column;
			&__title{
				font-size: 30rpx;
				color: #8a460d;
				font-weight: 500;
			}
			&__deilte{
				font-size: 22rpx;
				color: #a37632;
				margin-top: 10rpx;
			}
		}
		&__right{
			width: 180rpx;
			height: 60rpx;
			text-align: center;
			background-color: #ffffff;
			color: #ce7727;
			font-size: 28rpx;
			line-height: 60rpx;
			border-radius: 10rpx;
		}
	}
		
	.typetag {

		white-space: nowrap;
		font-size: 20rpx;
		color: #FFFFFF;
		padding: 0 10rpx;
		height: 28rpx;
		margin-left: 10rpx;
		line-height: 28rpx;
		text-align: center;
		border-radius: 10rpx;
		background-color: #FF7676;
	}

	.centerTop {
		padding: 30rpx 30rpx 40rpx;
		padding-top: 0rpx;
		position: relative;
		box-sizing: border-box;

		&__view {
			display: flex;
			align-items: center;
			justify-content: space-between;

			&__topview {
				display: flex;
				align-items: center;

				&__info {
					display: flex;
					flex-direction: column;
					margin-left: 30rpx;

					&__nickname {
						font-size: 32rpx;
					}

					&__account {
						font-size: 24rpx;
						color: #61626E;
					}
				}
			}
		}

		&__signature {
			margin-top: 40rpx;
			font-size: 28rpx;
			color: #61626E;
		}
	}

	.cellviewGrop {
		background: #ffffff;
		border-radius: 20rpx;
		margin: 0 30rpx 20rpx;

		.cellview {
			display: flex;
			justify-content: space-between;
			padding: 0 35rpx;
			height: 110rpx;

			&__left {
				display: flex;
				align-items: center;
				
				&__img {
					width: 40rpx;
					height: 40rpx;
				}

				&__title {
					font-size: 28rpx;
					margin-left: 20rpx;
					// background-image: linear-gradient(180deg,
					// 		rgba(255, 255, 255, 1) 0,
					// 		rgba(182, 139, 77, 1) 100%);
					color: #333333;
					// -webkit-background-clip: text;
					// -webkit-text-fill-color: transparent;
				}
				&__invite{
					font-size: 36rpx;
					margin-left: 20rpx;
					font-weight: 600;
					// background-image: linear-gradient(90deg,
					// 		rgba(251, 157, 16, 1) 0,
					// 		rgba(254, 228, 120, 1) 100%);
					color: #ffc168;
					// -webkit-background-clip: text;
					// -webkit-text-fill-color: transparent;
				}
			}
			&__right{
				display: flex;
				align-items: center;
				&__deilis{
					font-size: 28rpx;
					color: #B2B2B2;
					margin-top: -5rpx;
				}
				&__success{
					font-size: 28rpx;
					background-image: linear-gradient(90deg,
							rgba(247, 211, 142, 1) 0,
							rgba(241, 191, 115, 1) 100%);
					color: rgba(255, 255, 255, 1);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
					margin-top: -5rpx;
				}
				&__failed{
					font-size: 28rpx;
					color:#FF7676;
					margin-top: -5rpx;
				}
				&__invite{
					font-size: 36rpx;
					margin-left: 20rpx;
					font-weight: 600;
					// background-image: linear-gradient(90deg,
					// 		rgba(251, 157, 16, 1) 0,
					// 		rgba(254, 228, 120, 1) 100%);
					color: #ffc168;
					// -webkit-background-clip: text;
					// -webkit-text-fill-color: transparent;
				}
			}
			&__right{
				display: flex;
				align-items: center;
				&__deilis{
					font-size: 28rpx;
					color: #B2B2B2;
					margin-top: -5rpx;
				}
				&__success{
					font-size: 28rpx;
					background-image: linear-gradient(90deg,
							rgba(247, 211, 142, 1) 0,
							rgba(241, 191, 115, 1) 100%);
					color: rgba(255, 255, 255, 1);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
					margin-top: -5rpx;
				}
				&__failed{
					font-size: 28rpx;
					color:#FF7676;
					margin-top: -5rpx;
				}
			}
		}
	}
</style>